<?php
/**
 * ooPHP - object oriented PHP framework
 * @author Kamil Mikolajczyk ( rego (at) gazeta (dot) pl )
 * @version 1.0
 *
 */

/**
 * Represents head section of html document
 * @author Kamil Mikolajczyk ( rego (at) gazeta (dot) pl )
 * @version 1.0
 */
 class Head
 {
 	/**
 	 * Lang
 	 * @var string
 	 */
	private $lang = null;
	
 	/**
 	 * CSS link
 	 * @var string
 	 */
	private $cssLink = null;
	
 	/**
 	 * Charset
 	 * @var string
 	 */
	private $charset = null;
	
 	/**
 	 * Title
 	 * @var string
 	 */
	private $title = null;
	
 	/**
 	 * Keywords
 	 * @var string
 	 */
	private $keywords = null;
	
 	/**
 	 * Description
 	 * @var string
 	 */
	private $description = null;
	
 	/**
 	 * Author
 	 * @var string
 	 */
	private $author = null;
 
	
 	/**
 	 * Constructor
 	 * Does nothing :)
 	 */
//	function Head()
//	{	}
	
	/**
	 * Constructor with all head elements
	 * @param $l language
	 * @param $cL link to .css file
	 * @param $c charset
	 * @param $t title
	 * @param $k keywords
	 * @param $d description
	 * @param $a author
	 */
	function Head($l=null, $cL=null, $c=null, $t=null, $k=null, $d=null, $a=null)
	{
		$this -> setLang($l);
		$this -> setCssLink($cL);
		$this -> setCharset($c);
		$this -> setTitle($t);
		$this -> setKeywords($k);
		$this -> setDescription($d);
		$this -> setAuthor($a);
	}
	
	/**
	 * Sets $lang in head
	 * @var string
	 */
	function setLang($o)
	{
		$this -> lang = $o;
	}
	
	/**
	 * Sets $cssLink in head
	 * @var string
	 */
	function setCssLink($o)
	{
		$this -> cssLink = $o;
	}
	
	/**
	 * Sets $charset in head
	 * @var string
	 */
	function setCharset($o)
	{
		$this -> charset = $o;
	}
	
	/**
	 * Sets $title in head
	 * @var string
	 */
	function setTitle($o)
	{
		$this -> title = $o;
	}
	
	/**
	 * Sets $keywords in head
	 * @var string
	 */
	function setKeywords($o)
	{
		$this -> keywords = $o;
	}
	
	/**
	 * Sets $description in head
	 * @var string
	 */
	function setDescription($o)
	{
		$this -> description = $o;
	}
	
	/**
	 * Sets $author in head
	 * @var string
	 */
	function setAuthor($o)
	{
		$this -> author = $o;
	}
	
	/**
	 * Renders whole head section with all not null elements
	 */
	function render($indents = 0)
	{
		Printer::writeln('<head>', $indents);
		if($this -> charset != null)
			Printer::writeln('<meta http-equiv="content-type" content="text/html; charset='.$this -> charset.'" />', 1 + $indents);
		if($this -> keywords != null)
			Printer::writeln('<meta name="keywords" content="'.$this -> keywords.'" />', 1 + $indents);
		if($this -> description != null)
			Printer::writeln('<meta name="description" content="'.$this -> description.'" />', 1 + $indents);
		if($this -> lang != null)
			Printer::writeln('<meta name="lang" content="'.$this -> lang.'" />', 1 + $indents);
		if($this -> author != null)
			Printer::writeln('<meta name="author" content="'.$this -> author.'" />', 1 + $indents);
		if($this -> title != null)
			Printer::writeln('<title>'.$this -> title.'</title>', 1 + $indents);		
		if($this -> cssLink != null)
			Printer::writeln('<link rel="stylesheet" href="'.$this -> cssLink.'" type="text/css" />', 1 + $indents);
		Printer::writeln('</head>', $indents);
	}
 }
 ?>